Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Property | Value |
---|---|
Rule ID | CA1724 |
Title | Type names should not match namespaces |
Category | Naming |
Fix is breaking or non-breaking | Breaking |
Enabled by default in .NET 9 | No |
A type name matches a referenced namespace name that has one or more externally visible types. The name comparison is case-insensitive.
User-created type names should not match the names of referenced namespaces that have externally visible types. Violating this rule can reduce the usability of your library.
Rename the type such that it doesn't match the name of a referenced namespace that has externally visible types.
For new development, no known scenarios occur where you must suppress a warning from this rule. Before you suppress the warning, carefully consider how the users of your library might be confused by the matching name. For shipping libraries, you might have to suppress a warning from this rule.
If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.
#pragma warning disable CA1724
// The code that's violating the rule is on this line.
#pragma warning restore CA1724
To disable the rule for a file, folder, or project, set its severity to none
in the configuration file.
[*.{cs,vb}]
dotnet_diagnostic.CA1724.severity = none
For more information, see How to suppress code analysis warnings.
namespace MyNamespace
{
// This class violates the rule
public class System
{
}
}
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register now