Solved

How do you handle namespace conflicts?

Posted on 2009-04-10
9
300 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
  • 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
 
LVL 22

Expert Comment

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

you can do MyAppSecurity
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

947 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now