Solved

How do you handle namespace conflicts?

Posted on 2009-04-10
9
304 Views
Last Modified: 2012-05-06
I use fxcop and one of the violations is to use an existing .NET namespace such as Configuration, ConfigurationManager, Security.  I like the rule.  It avoids namespace conflicts.  But what are some other names to give those spaces?  How are others naming them?
0
Comment
Question by:brettr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
9 Comments
 
LVL 12

Accepted Solution

by:
williamcampbell earned 250 total points
ID: 24117931
You can have a global namespace for you product or company

namespace bretterscoolcode.configuration
{
}

namespace okcompany.bretteriscooler.code.configuration
{
}

Use the dots luke ..

0
 
LVL 22

Assisted Solution

by:p_davis
p_davis earned 250 total points
ID: 24117934
How about prefixing the names with your applications name?
0
 

Author Comment

by:brettr
ID: 24118006
Using dots like thecompany.Enterprise.Configuration makes no difference.  fxcop will even point out the fully qualified namespace is incorrect:

Error, Certainty 95, for TypeNamesShouldNotMatchNamespaces
{
    Target       : mycompany.Enterprise.Configuration  (IntrospectionTargetType)
    Resolution   : "The type name 'Configuration' conflicts in whole
                   or in part with the namespace name 'System.Configuration'
                   defined in the .NET Framework. Rename the type to eliminate
                   the conflict."
    Help         : http://msdn2.microsoft.com/ms182257(VS.90).aspx  (String)
    Category     : Microsoft.Naming  (String)
    CheckId      : CA1724  (String)
    RuleFile     : Naming Rules  (String)
    Info         : "Identifiers which conflict in whole or in part with
                   namespace names should be avoided. Names that describe
                   the purpose or contents of a type are preferred."
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:p_davis
ID: 24118024
i meant like if your application was called MyApp

you can do MyAppSecurity
0
 
LVL 22

Expert Comment

by:p_davis
ID: 24118026
or use acronyms

MASecurity
0
 

Author Comment

by:brettr
ID: 24118145
I was referring to williamcampbell.  I don't want to use the company name or acronums of it in the namespace.  Cheesy.
0
 
LVL 22

Expert Comment

by:p_davis
ID: 24118172
You asked for suggestions, i gave one. I don't think there is a reason to make fun of a suggestion that is perfectly valid.
0
 
LVL 12

Expert Comment

by:williamcampbell
ID: 24118243
Go into fxcop and turn of this warning ... it's stupid in my opioion

mmm cheese

0
 
LVL 22

Expert Comment

by:p_davis
ID: 24118260
that's it, now i am hungry.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question