Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Design Warnings
 Avoid namespaces with few types
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:

Want more? Here are some additional resources on this topic:

Visual Studio Team System
Avoid namespaces with few types

TypeName

AvoidNamespacesWithFewTypes

CheckId

CA1020

Category

Microsoft.Design

Breaking Change

Breaking

A namespace other than the global namespace contains fewer than five types.

Make sure that there is a logical organization to each of your namespaces, and that there is a valid reason for putting types in a sparsely populated namespace. Namespaces should contain types that are used together in most scenarios. When their applications are mutually exclusive, types should be located in separate namespaces. For example, the System.Web.UI namespace contains types that are used in Web applications, and the System.Windows.Forms namespace contains types that are used in Windows-based applications. Even though both namespaces have types that control aspects of the user interface, these types are not designed to be used in the same application, and are therefore located in separate namespaces. Careful namespace organization can also be helpful because it increases the discoverability of a feature. By examining the namespace hierarchy, library consumers should be able to locate the types that implement a feature.

NoteNote

Design-time types and permissions should not be merged into other namespaces to comply with this guideline. These types belong in their own namespaces below your main namespace, and the namespaces should end in .Design and .Permissions, respectively.

To fix a violation of this rule, try to combine namespaces that contain a small number of types into a single namespace.

It is safe to exclude a warning from this rule when the namespace does not contain types that are used with the types in your other namespaces.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Only applicable to reusable libraries      David M. Kean - MSFT   |   Edit   |  

This rule is only applicable if you are designing reusable libraries.

If you are developing a normal application, you can turn it off by doing the following:

  1. In Solution Explorer, right-click your project and choose Properties
  2. In the Project Properties window, select the Code Analysis tab
  3. Expand the Design node and uncheck the CA1020: Avoid namespaces with few types
  4. Choose File -> Save Selected Items
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker